package com.stm.basicData.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.stm.basicData.domain.SysWarnningConfig;
import com.stm.basicData.mapper.SysWarnningConfigMapper;
import com.stm.basicData.service.SysWarnningConfigService;
import com.stm.common.annotation.DataScope;
import com.stm.common.core.text.Convert;
import com.stm.common.exception.BusinessException;
import com.stm.common.utils.DateUtils;

/**
 * 
 * @Description 超期颜色配置SysWarnningConfigimpl
 * @CreateTime 2019年4月4日 上午8:43:59
 * @CreateBy 林龙
 */
@Service
public class SysWarnningConfigServiceImpl implements SysWarnningConfigService
{
    @Autowired
    private SysWarnningConfigMapper sysWarnningConfigMapper;
    

    /**
     * 根据条件分页查询数据
     * 
     * @param kfTools 信息
     * @return list集合信息
     */
    @Override
    @DataScope(tableAlias = "b2")
    public List<SysWarnningConfig> selectAllPageList(SysWarnningConfig sysWarnningConfig){
        return sysWarnningConfigMapper.selectAllPageList(sysWarnningConfig);
    }

    /**
     * 根据id查询信息
     * 
     * @param id 
     * @return 对象信息
     */
    @Override
    public SysWarnningConfig selectByPrimaryKey(){
        return sysWarnningConfigMapper.selectByPrimaryKey();
    }

    /**
     * 新增保存信息
     * 
     * @param sysWarnningConfig RFID信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insert(SysWarnningConfig sysWarnningConfig){
    	UUID uuid = UUID.randomUUID();
    	sysWarnningConfig.setId(uuid.toString());
    
    	sysWarnningConfig.setCreateTime(DateUtils.getNowDate());
//    	sysWarnningConfig.setApplyDate(DateUtils.getNowDate());
//    	sysWarnningConfig.setStatus("1");
//    	sysWarnningConfig.setTestDate(DateUtils.getNowDate());
//    	sysWarnningConfig.setApplyDeptId(sysWarnningConfig.getTestDeptId());
    	
    	//工具试验申请表
    	return sysWarnningConfigMapper.insertSelective(sysWarnningConfig);
    }

	/**
     * 修改保存信息
     * 
     * @param sysWarnningConfig RFID信息
     * @return 结果
     */
    @Override
    @Transactional
    public int update(SysWarnningConfig sysWarnningConfig){
    	return  sysWarnningConfigMapper.updateByPrimaryKeySelective(sysWarnningConfig);
    }
    
    /**
     * 批量删除
     * 
     * @param ids
     * @throws Exception
     */
    @Override
    public int deleteByPrimary(String ids) throws BusinessException
    {
        String[] sysWarnningConfigIds = Convert.toStringArray(ids);
        
        	return sysWarnningConfigMapper.deleteByPrimary(sysWarnningConfigIds);
    }

   

}
